<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><%= title %></title>

	<% include ../includes/head%>
</head>
<body>
<% include ../includes/header%>
	

	<div id="container-inner">
		<ul id="breadcrumb-wrapper">
        
	    	<li>
	            <a href="index.html">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	主页
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>  
            
            <li>
	            <a href="blog.html">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	新闻列表
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>
            
           
            <li id="page-title">
          		新闻列表
        	</li><!--page-title-->
        </ul>
        <div id="inner-border"></div>
        <div class="clear"></div>
        <div id="contentwrap-inner">
        	
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>图片标题</th>
						<th>简介</th>
						
						<th>录入时间</th>
						
						<th>更新</th>
						<th>删除</th>
					</tr>
					
					<tbody>
						<% for(var i = 0; i < pictures.length; i++){%>
						<tr class="item-id-<%= pictures[i].id%>">
							<td>
								<%= pictures[i].title%>
							</td>
							<td>
								<%= pictures[i].summary%>
							</td>
							
							<td>
								<%= moment(pictures[i].meta.createAt).format('YYYY/MM/DD') %>
							</td>
							
							<td>
								<a href="../pictureUpdate/<%= pictures[i]._id %>">修改</a>
							</td>
							<td>
								<button type="button" data-id="<%= pictures[i]._id%>" class="btn btn-danger del">删除</button>		
							</td>
						</tr>
						<%}%>
					</tbody>
					
				</thead>
			</table>
			<div class="clear"></div>
        </div>		
	</div>
	<% include ../includes/footer%>
	<script>
		$(function(){
		    $('.del').click(
		        function(e){
		            var target = $(e.target);
		            var id = target.data('id');
		            var tr  = $('.item-id-'+ id);
		            $.ajax({
		                type:'DELETE',
		                url:'/admin/picturelist?id='+id
		            })
		                .done(function(reaults){
		                    if(reaults.success===1){
		                        if(tr.length>0){
		                            tr.remove();
		                        }
		                    }
		                })
		        }
		    )
		})
	</script>
</body>
</html>